import request from '@/utils/request'

// 获取验证码
export function getVerifyCode(email) {
  return request({
    url: '/auth/user/code',
    method: 'post',
    data: { email }
  })
}

// 登录
export function login(data) {
  return request({
    url: '/auth/user/doLogin',
    method: 'post',
    data
  })
}

// 注册
export function registerUser(email) {
  return request({
    url: '/auth/user/register',
    method: 'post',
    data: { email }
  })
}

//退出登录
export function logout() {
    return request({
      url: '/auth/user/logout',
      method: 'get'
    })
  }

// 获取用户信息
export function getUserInfo() {
  return request({
    url: '/auth/userInfo/info',
    method: 'get'
  })
}

// 修改用户信息
export function updateUserInfo(data) {
  return request({
    url: '/auth/userInfo/update',
    method: 'post',
    data
  })
}

//删除用户
export function deleteUser(id) {
    return request({
      url: '/auth/userInfo/delete',
      method: 'get',
      params: { id }
    })
  }

//用户条件查询
export function search(email,username,uid) {
    return request({
      url: '/auth/userInfo/search',
      method: 'get',
      params: { email,username,uid }
    })
  }

// 获取用户列表
export function getUserList(pageNum, pageSize) {
  return request({
    url: '/auth/userInfo/list',
    method: 'get',
    params: { pageNum, pageSize }
  })
}

//禁用启动用户
export function start(id) {
    return request({
      url: '/auth/userInfo/status',
      method: 'get',
      params: { id }
    })
  }

  // 上传头像
export function uploadAvatar(file) {
    const formData = new FormData()
    formData.append('file', file)
    return request({
      url: '/oss/uploadFile',
      method: 'post',
      data: formData,
      headers: {
        'Content-Type': 'multipart/form-data'
      }
    })
  }